﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class key_dealer_play : System.Web.UI.Page
{

    ClassDB.DB TradeDB = new ClassDB.DB();
    DataTable ds;
  DataTable workTable = new DataTable("Customers");
      
 DataRow workRow;

       


    protected void Page_Load(object sender, EventArgs e)
    {
       // binddata();

        if (!IsPostBack)
        {
            workTable.Columns.Add("key_number", typeof(int));
            workTable.Columns.Add("key_money", typeof(string));
        }
    }
    protected void btnsent_Click(object sender, EventArgs e)
    {
        Array arr_str = txt_value.Text.Split('*');
        String[] GetArray = (String[])arr_str;

        int sumnum = 0;

        for (int i = 0; i < GetArray.Length ; i++)
        {

            sumnum = sumnum + Convert.ToInt32(GetArray[i]);
        }


       lbl_subtotal.Text = sumnum.ToString();


        //------------------------------------------------------------------------------------


       workRow = workTable.NewRow();
       workRow["key_number"] = txt_number.Text;
       workRow["key_money"] = txt_value.Text;
       workTable.Rows.Add(workRow);


       //for (int i = 0; i <= 59; i++)
       //{
       //    workRow = workTable.NewRow();
       //    workRow["key_number"] = i;
       //    workRow["key_money"] = "CustName" + i.ToString();
       //    workTable.Rows.Add(workRow);
       //}


     //  DataView view = new DataView(workTable);
      // view.Sort = "key_number ASC";



       int plus = 0;


     //  foreach (DataRowView row in view)
      // {
          // plus = plus + Convert.ToInt16(row["key_money"]);
     //  }

     //  Response.Write(plus);


       DataList.DataSource = workTable;
       DataList.DataBind();






       //string sql = "exec proc_ticket @ITYPE='S02',@ID='" + txt_number.Text + "',@MONEY='" + txt_value.Text + "',";
       //sql += " @TOTAL='" + sumnum + "',@USER='002',@TYPE='1' ,@SessioID= '" + Session.SessionID +"'";
       //TradeDB.ExeCom(sql);

       //binddata();


       txt_number.Text = null;
       txt_value.Text = null;
      // txt_money.Text = null;
       txt_number.Focus();



    }




    private void binddata()
    {
        string sql = "exec proc_ticket @ITYPE = 'S01',@SessioID= '" + Session.SessionID + "'";
        TradeDB.ShowTable(sql, "temp");

       // GrdData.DataSource = TradeDB.Ds.Tables[0];
      //  GrdData.DataBind();


        DataList.DataSource = TradeDB.Ds.Tables[0];
        DataList.DataBind();


    }
    protected void DataList_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        
    }
}